#include<bits/stdc++.h>
#define int long long
#define N 100000 + 7
//#define DEBUG

using namespace std;

int n, r[N], gs[N], cnt=1, sum[N], ans;

bool check(int x){
    return sum[cnt-1] - sum[x] >= sum[x];
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef DEBUG
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    #endif // DEBUG
    #ifdef DEBUG
    //freopen("duel4.in", "r", stdin);
    #endif // DEBUG
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> r[cnt];
        gs[r[cnt]]++;
        if(gs[r[cnt]] == 1){
            cnt++;
        }
    }
    sort(r+1, r+cnt);
    if(cnt == 2){
        cout << n;
        return 0;
    }
    for(int i=1; i<cnt; i++){
        sum[i] = sum[i-1] + gs[r[i]];
        //cout << sum[i] << " ";
    }
    ans = n;
    int lt = 1, rt = 2, dtt = sum[1], fl = 0;
    while(rt < cnt){
        while(sum[rt] - sum[lt] < dtt){
            if(rt >= cnt - 1){
                fl = 1;
                break;
            }
            rt++;
        }
        if(fl){
            ans = ans - (sum[rt] - sum[lt]);
            break;
        }
        ans -= dtt;
        dtt = sum[rt] - sum[lt];
        lt = rt;
        rt++;
    }
    cout << ans;
    return 0;
}
